<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>门诊收费</title>
<script type="text/javascript" src="static/easyui/jquery.min.js"></script>
<script type="text/javascript" src="static/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="static/easyui/locale/easyui-lang-zh_CN.js"></script>
</head>
<body>
<script type="text/javascript">
         $(function(){
        	  //打印小票----药物表格
    		 $("#drugtickettmonoy-tab").datagrid({
			    columns:[[
			    		{field:'docdetails_id',title:'',hidden:true},
			    		{field:'category_name',title:'药品类别',width:141.4},
						{field:'drug_name',title:'药品名称',width:141.4},
						{field:'drug_retail_price',title:'药品单价',width:141.4},
						{field:'drug_unit',title:'单位',width:141},
						{field:'docdetails_everynnum',title:'药品数量',width:141}
			    ]]
    		 });
    		 
    		 //打印小票----体检
    		 $("#healthtickettmonoy-tab").datagrid({
 			    columns:[[
 			    		 {field:'project_no',hidden:true},
 			    		 {field:'project_name',title:'体检名称',width:353},
 						 {field:'project_price',title:'价格',width:352}
 			    ]]
     		 });
    		 
    		 //打印小票----医疗项目
    		 $("#hostickettmonoy-tab").datagrid({
  			    columns:[[
  			  			{field:'hospital_project_id',hidden:true},
  			    		{field:'hospital_project_name',title:'医疗项目名称',width:353},
  						{field:'hospital_project_price',title:'价格',width:352}
  			    ]]
      		 });
  			
  			//医疗卡号搜索网格
      		$("#mclinic-sreachbox").searchbox({
      				searcher:function(value,name){
      					var rows=$("#chargemoney-clinic-tab").datagrid("getRows");
      					if(rows.length==0){
      						$.messager.confirm('Confirm', 
									'暂无需要收费人', 
									function(r){
						     });
      					}else{
      						$("#chargemoney-clinic-win").window("open");
      					}
      				}
      			});
             	
             	$("#chargemoney-clinic-tab").datagrid({
             		url:'select-healthclinicid',
        			    pagination:true,
        			    pageNumber:1,
        			    pageSize:10,
        			    pageList:[10,20],
        			    columns:[[
        			    		{field:'clinic_id',title:'医疗编号',width:126,hidden:true},
        			    	 	{field:'cliniccard_id',title:'医疗卡号',width:126},
        			    		{field:'clinic_name',title:'病人名字',width:120},
        						{field:'clinic_sex',title:'性别',width:50},
        						{field:'clinic_idnumber',title:'身份证号',width:160},
        						{field:'clinic_tel',title:'电话',width:120},
        						{field:'clinic_address',title:'家庭住址',width:153},
        						{field:'clinic_remainmoney',title:'余额',width:80}
        			    ]]
             	});
             	
             	//双击获取
     			$("#chargemoney-clinic-tab").datagrid({
     				onDblClickRow: function(rowIndex,rowData){
     					     //医疗卡
		                     $("#mclinic-sreachbox").textbox('setValue',rowData['cliniccard_id']); 
		                     $("#mclinic-sreachbox").textbox('readonly','true');
		                     //医疗卡号--自主体检打印小票
	  		                 $("#ticket_ucliniccard2").text(rowData['cliniccard_id']); 
	  		                 
  		                     //患者姓名
  		                     $("#chargemoney-sickuname").textbox('setValue',rowData['clinic_name']); 
  		                     $("#ticket_uname2").text(rowData['clinic_name']); 
			                     
  		                    //患者性别
  		                    $("#chargemoney-patientsex").combobox('setValue',rowData['clinic_sex']);
  		                    $("#ticket_usex2").text(rowData['clinic_sex']);
  		                  
  		                    //身份证号
  		                    $("#chargemoney-sickusercard").textbox('setValue',rowData['clinic_idnumber']);
  		                    //手机号码
  		                    $("#chargemoney-sickuserTel").textbox('setValue',rowData['clinic_tel']);
  		                    //家庭住址
  		                    $(".caddress").textbox('setValue',rowData['clinic_address']);
  		                   //余额
		                   $(".clinic_remainmoney").textbox('setValue',rowData['clinic_remainmoney']);
		                    
		                    //关闭窗口
		               	   $("#chargemoney-clinic-win").window("close");
     				}
     		  				
     			});
  	
        	 
           	 //处方收费
        	 $(".drugmoney").click(function(){
        		 //不能直接打开弹框
        		 //看诊号的框
        		 var looknumber=$("#chargemoney-sreachbox").textbox("getValue");
        		 var lookname=$("#chargemoney-sickuname").textbox("getValue");
        		 if(looknumber!="" && lookname!=""){
        			 //打开弹框
		             $("#drugmoney-win").window('open');
        			 //获取看诊号
        			 var lid=$("#chargemoney-sreachbox").textbox("getValue");
        			/*  alert(lid); */
        	       	 //弹框药物收费
                	 $('#drugmoneytab').datagrid({
        			    url:'select-drugMoney?lookids='+lid,
        			    method:'post',
        			    pagination:true,
        			    pageNumber:1,
        			    pageSize:10,
        			    pageList:[10,20],
        			    columns:[[
        					    {field:'docadvice_id',title:'医嘱id',hidden:true},
        			    		{field:'docdetails_id',title:'医嘱详情id',hidden:true},
        			    		{field:'category_name',title:'药品类别',width:114},
        			    	 	{field:'drug_number',title:'药品编号',width:114},
        						{field:'drug_name',title:'药品名称',width:212},
        						{field:'drug_retail_price',title:'药品单价',width:119},
        						{field:'drug_unit',title:'单位',width:114},
        						{field:'docdetails_everynnum',title:'药品数量',width:110}
        			    ]],
        			    onLoadSuccess:function(data){ 
                   		    	//获取表格所有数据
                               	var rows = $("#drugmoneytab").datagrid("getRows");
               					//药品总金额
               					var totals=0;
               					for (var i = 0; i < rows.length; i++) {
               						console.log("单价：-----"+rows[i].drug_retail_price+"数量：-----"+rows[i].docdetails_everynnum);
               						 //总金额
               					    totals=totals+parseInt(rows[i].drug_retail_price)*parseInt(rows[i].docdetails_everynnum);
               					}
       							console.log("应收：-----"+totals);
       							 //应收金额
       							$("#drugMoneys").text(totals);
       						    //默认实收为应收金额
       						    //$("#drugshishou").val(totals);
       						    //默认找零
       						    $("#drugfoundZero").text("0");
       						   
       							 //支付方式判断----医疗卡支付首先判断余额是否充足---充足就修改余额并且新增交易记录
       							 //获取支付方式---医疗卡0，现金1
       							 var charge_moneytype=$(".charge-moneytype").val();
       							 var  clinic_remainmoney=$(".clinic_remainmoney").textbox('getValue');
       							 var clinic_ids=$(".clinic_ids").textbox('getValue');
       							console.log("药物----支付方式:"+charge_moneytype+"药物----余额:"+clinic_remainmoney);
       							 if(charge_moneytype==0 && parseInt(totals)>  parseInt(clinic_remainmoney)){
       								 //alert(charge_moneytype+"医疗卡支付"+"-----医疗卡主键："+clinic_ids);
       								 //药物金额大于余额
       								 $.messager.confirm('Confirm', 
       	  		     							'你的余额不足,请去医疗卡管理充值', 
       	  		     							function(r){
       	  		     				});
       							 }/* charge_moneytype==0 */
        			    }
        			});
                  
        		 }else{
        			 $.messager.confirm('Confirm', 
								'请选择收费的人！！！', 
								function(r){
					     });
        		 }
        			 
        	 });
           	 
        		//体检项目收费
        	 $(".checkup-moneybtn").click(function(){
        		 var lids=$("#chargemoney-sreachbox").textbox("getValue");
        	    //门诊体检---判断
        		 if(lids!=""){
        			console.log("门诊体检"+lids);
                 	 //弹框体检项目收费
                	 $('#checkuphealth-money').datagrid({
         			    url:'select-healMoney?lid='+lids,
         			    pagination:true,
         			    pageNumber:1,
         			    pageSize:10,
         			    pageList:[10,20],
         			    columns:[[
         			    	 	{field:'health_no',hidden:true},
         			    	 	{field:'project_no',title:'项目编号',hidden:true},
         			    	 	{field:'project_name',title:'体检名称',width:391.4},
         			    	 	{field:'project_price',title:'价格',width:390},
         						{field:'section_name',title:'科室',width:259.8,hidden:true}
         			    ]] ,
		     			 onLoadSuccess:function(data){
		     		   	       	 //获取表格所有数据
		                     	var rows = $("#checkuphealth-money").datagrid("getRows");
		     					//药品总金额
		     					var totals=0;
		     					for (var i = 0; i < rows.length; i++) {
		     						 //总金额
		     					    totals=totals+parseInt(rows[i].project_price);
		     					}
									console.log("应收：-----"+totals);
									 //应收金额
									$("#outHealthMoneys").text(totals);
									 //默认实收为应收金额
	       							 //$(".outHealthshishou").val(totals);
	       							 //默认找零
	        						 $("#outHealthfoundZero").text("0");
									 
									//支付方式判断----医疗卡支付首先判断余额是否充足---充足就修改余额并且新增交易记录
									 //获取支付方式---医疗卡0，现金1
									 var charge_moneytype=$(".charge-moneytype").val();
									 var  clinic_remainmoney=$(".clinic_remainmoney").textbox('getValue');
									 var clinic_ids=$(".clinic_ids").textbox('getValue');
									console.log("门诊体检----支付方式:"+charge_moneytype+"药物----余额:"+clinic_remainmoney);
									 if(charge_moneytype==0 && parseInt(totals)>  parseInt(clinic_remainmoney)){
										 console.log(charge_moneytype+"医疗卡支付"+"-----医疗卡主键："+clinic_ids);
										 //药物金额大于余额
										 $.messager.confirm('Confirm', 
			  		     							'你的余额不足,请去医疗卡管理充值', 
			  		     							function(r){
			  		     				});
									 }/* charge_moneytype==0 */
		     			  }
         			});
            		$("#checkupmoneyhealth-win").window('open');
        		 }else{//自主体检----看诊号为空
        			 var cid=$("#mclinic-sreachbox").textbox("getValue");
        		    // alert("自主体检："+cid);
        			 $('#checkuphealth-money').datagrid({
          			    url:'select-selfhealthmoney?cid='+cid,
          			    pagination:true,
          			    pageNumber:1,
          			    pageSize:10,
          			    pageList:[10,20],
          			    columns:[[
          			    	 	{field:'appo_no',title:'预约编号',width:260},
          			    		{field:'project_id',hidden:true},
          			    	 	{field:'project_name',title:'体检名称',width:262},
          			    	 	{field:'project_price',title:'价格',width:260},
          						{field:'section_name',title:'科室',width:195,hidden:true}
          			    ]] ,
			     			 onLoadSuccess:function(data){
			     		   	       	 //获取表格所有数据
			                     	var rows = $("#checkuphealth-money").datagrid("getRows");
			     					//药品总金额
			     					var totals=0;
			     					for (var i = 0; i < rows.length; i++) {
			     						 //总金额
			     					    totals=totals+parseInt(rows[i].project_price);
			     					}
										console.log("应收：-----"+totals);
										 //应收金额
										$("#outHealthMoneys").text(totals);
										 //默认实收为应收金额
		       							 //$(".outHealthshishou").val(totals);
		       							 //默认找零
		        						 $("#outHealthfoundZero").text("0");
										 
										//支付方式判断----医疗卡支付首先判断余额是否充足---充足就修改余额并且新增交易记录
										 //获取支付方式---医疗卡0，现金1
										 var charge_moneytype=$(".charge-moneytype").val();
										 var  clinic_remainmoney=$(".clinic_remainmoney").textbox('getValue');
										 var clinic_ids=$(".clinic_ids").textbox('getValue');
										 console.log("自主体检----支付方式:"+charge_moneytype+"----余额:"+clinic_remainmoney);
										 if(charge_moneytype==0 && parseInt(totals)>  parseInt(clinic_remainmoney)){
											 console.log(charge_moneytype+"医疗卡支付"+"-----医疗卡主键："+clinic_ids);
											 //药物金额大于余额
											 $.messager.confirm('Confirm', 
				  		     							'你的余额不足,请去医疗卡管理充值', 
				  		     							function(r){
				  		     				});
										 }/* charge_moneytype==0 */
										 
			     			  }
          			 });
             			$("#checkupmoneyhealth-win").window('open');
        		 }
        	 });
        	 
        	 
        	//医疗项目收费
        	 $(".lookdoctormoney").click(function(){
        		 //不能直接打开弹框
        		 //看诊号的框
        		 var looknumber=$("#chargemoney-sreachbox").textbox("getValue");
        		 var lookname=$("#chargemoney-sickuname").textbox("getValue");
        		 if(looknumber!="" && lookname!=""){
        		      var lid=$("#chargemoney-sreachbox").textbox("getValue");
        			 $('#hospitalhealth-money').datagrid({
            			    url:'select-HosptialMoney',
            			    queryParams:{
            			    	llid:lid
       			    	    },
            			    pagination:true,
            			    pageNumber:1,
            			    pageSize:10,
            			    pageList:[10,20],
            			    columns:[[
            			    		{field:'hosp_look_id',hidden:true},
            			    		{field:'hosp_lookdetails_id',hidden:true},
            			    	 	{field:'hospital_project_id',title:'项目编号',width:260},
          			    	 	    {field:'hospital_project_name',title:'项目名称',width:262},
          						    {field:'hospital_project_price',title:'价格',width:260}
            			    ]],
	   		     			 onLoadSuccess:function(data){
	   		     				
		     		   	       	 //获取表格所有数据
		                     	var rows = $("#hospitalhealth-money").datagrid("getRows");
		     					//药品总金额
		     					var totals=0;
		     					for (var i = 0; i < rows.length; i++) {
		     						 //总金额
		     					    totals=totals+parseInt(rows[i].hospital_project_price);
		     					}
									console.log("应收：-----"+totals);
									 //应收金额
									$("#hosProjectMoneys").text(totals);
									 //默认实收为应收金额
	       							 //$(".hosProjectshishou").val(totals);
	       							 //默认找零
	        						 $("#hosProjectfoundZero").text("0");
	       							 
									//支付方式判断----医疗卡支付首先判断余额是否充足---充足就修改余额并且新增交易记录
									 //获取支付方式---医疗卡0，现金1
									 var charge_moneytype=$(".charge-moneytype").val();
									 var  clinic_remainmoney=$(".clinic_remainmoney").textbox('getValue');
									 var clinic_ids=$(".clinic_ids").textbox('getValue');
									 //alert("医疗项目---支付方式:"+charge_moneytype+"----余额:"+clinic_remainmoney);
									 if(charge_moneytype==0 && parseInt(totals)>  parseInt(clinic_remainmoney)){
										 console.log(charge_moneytype+"医疗卡支付"+"-----医疗卡主键："+clinic_ids);
										 //金额大于余额
										 $.messager.confirm('Confirm', 
			  		     							'你的余额不足,请去医疗卡管理充值', 
			  		     							function(r){
			  		     				});
									 }/* charge_moneytype==0 */
		     			  }
            			});
          			$("#lookmoney-win").window('open');
        		 }else{
        			 $.messager.confirm('Confirm', 
								'请选择收费的人！！！', 
								function(r){
					     });
     		     }
        	});
        	
           //自主体检与门诊体检收费提交
           $("#submit-chekhealthmoney").click(function(){
        	     //获取看诊号文本框-----无看诊号就是自主体检
        	  	 var lids=$("#chargemoney-sreachbox").textbox("getValue");
        	     //获取表格里面的内容
      			var row_project = $("#checkuphealth-money").datagrid("getRows");
         	    //门诊体检---判断
         		 if(lids!=""){
         			//console.log("门诊体检收费项目："+row_project);
        			//获取看诊号
     				var look_id =$("#chargemoney-sreachbox").textbox("getValue");
     				//项目编号的数组
     				var project_arr = [];
     				//经办人
     				var  chargename=$("#chargename").val();
     				//项目的总金额
     				var totalmoney=null;
     				for(var i=0;i<row_project.length;i++){
     					project_arr.push(row_project[i].health_no);
     					totalmoney +=row_project[i].project_price;
     				}
     				parseFloat(totalmoney);
     				$.ajax({
     					url:'add-outhealthMoney?healthno_arr='+project_arr+'&look_id='+look_id+'&totalmoney='+totalmoney,
     					method:'Post',
     					Type:'json',
     					data:{
     						"chargename":chargename
     					},
     					success:function(data){
     						$(".window-tishi").text("门诊体检收费成功,正在打印小票.....");
    				    	$("#charge-saveclinic-win").window('open');
    				    	//三秒之后自动消失
    					   setTimeout(function(){
    					    	 $("#charge-saveclinic-win").window('close');
    						 }, 3000);
     						  //新增交易记录
     						 var charge_moneytype=$(".charge-moneytype").val();
      				 		 if(charge_moneytype==0){
	     	    				  var clinic_ids=$(".clinic_ids").textbox('getValue');
	     						   $.ajax({
	     							   url:'add-chargeRechangeMoney',
	     						      type:'post',
	     						      data:{"clinic_ids":clinic_ids,"rechange_money": totalmoney},
	     						      success:function(data){
	     						    	  //alert(data);
	     						     }
	     						   });
      				 		 }
     						$("#checkupmoneyhealth-win").window('close');
     						//项目收费
       					 $('#chargemoneys-tab').datagrid('appendRow',{
       						 chargemoney_name:'门诊体检收费',
       						 chargemoney_allmoney:totalmoney
       					 });
     						
     					//打印小票---门诊体检
     					$(".healthtickettmonoy").css("display","block"); 
  						//获取表格中的信息
  						var drows =$("#checkuphealth-money").datagrid('getRows');
  					    //alert("drows:"+drows);
  						var copyRows = [];
  			            for (var j= 0; j < drows.length; j++) {
  			                copyRows.push(drows[j]); //将数据添加到copyRows数组中    
  			            }
  			            //alert("drows:"+drows+"------------copyRows:"+drows[j]);
  			            for(var i =0;i<copyRows.length;i++){ 
  							var falg = true;
  							var index = $('#checkuphealth-money').datagrid('getRowIndex',copyRows[i]);
  							//alert("index:"+index);
  							//获取追加的表格的行
  							var recordrows = $("#healthtickettmonoy-tab").datagrid("getRows");
  							for(var m=0;m<recordrows.length;m++){
  							     //判断该datagrid在将要添加的数据中是否存在
  							    /*  if(copyRows[i].project_no == recordrows[m].project_no){					      
  							        	falg = false; 
  							        	
  							     }    */							
  						    } 
  			                 if(falg){
  			                	  //alert("falg");
  			                	 $("#healthtickettmonoy-tab").datagrid('appendRow',{
  			                		 project_no:drows[i].project_no,
  			                		 project_name:drows[i].project_name,
  			                		 project_price:drows[i]. project_price
  				 		         });
  			                 }
  			            }
  			             //门诊票据单号
  			             var look_number=$("#chargemoney-sreachbox").textbox("getValue");
	  			          $.ajax({
						      url:'select-chargeMoneyNumber',
	   					      type:'post',
	   					      data:{"look_number":look_number,"chargemoney_name": "门诊体检收费"},
	   					      success:function(data){
	   					    	 $("#health_waternumber").text(data[0]["chargemoney_id"]);
	   					    	 var chtime=data[0]["chargemoney_time"];
	   					 	     $("#health_date").text( comFormatDate(chtime));
	   					      }
					    });  
  			            
     					//体检应收
     					$("#ticket_healthtotalmoney").text(totalmoney+"/元");
     					//实收
    					var shimoney=$(".outHealthshishou").val();
    					$("#ticket_healthshimoney").text(shimoney+"/元");
    					//找零
    					var zhaoling=$("#outHealthfoundZero").text(); 
    					$("#ticket_healthfoundzero").text(zhaoling+"/元");
    				
    					//打开弹框
    				    setTimeout(function(){
	    					  //打印小票弹框
	    					 $("#out-ticket-record-win2").window("open");
    					   }, 3000); 
    					
    					//关闭打印小票
    				    setTimeout(function(){
	    					  //打印小票弹框
	    					 $("#out-ticket-record-win2").window("close");
	    					 $("#checkuphealth-money").datagrid("loadData", {total:0, rows:[]});
	    					//清空实收
	 				    	$(".outHealthshishou").textbox("setValue","");
  					    },7000);
    				    //$("#healthtickettmonoy-tab").datagrid("loadData", {total:0, rows:[]});	
     					}
     				});
     				
         		 }else{//自主体检
         			//经办人
     				var  appno_chargename=$("#chargename").val();
         		    //项目数组
         			var appo_no_arr = [];
         		    //总金额
         			var  appo_totalmoney=null;
     				for(var i=0;i<row_project.length;i++){
     					appo_no_arr.push(row_project[i].appo_no);
     					appo_totalmoney +=row_project[i].project_price;
     					console.log("自主体检收费项目2222222222："+row_project[i].appo_no);
     				}
     				parseFloat(appo_totalmoney);
     				$.ajax({
     					url:'add-SelfhealthMoney?appo_no_arr='+appo_no_arr+"&chargename="+appno_chargename+"&totalmoney="+appo_totalmoney,
     					type:'post',
     					dataType:'json',
     					success:function(data){
     					 if(parseInt(data)==1){
     						$(".window-tishi").text("自主体检收费成功,正在打印小票......");
    				    	$("#charge-saveclinic-win").window('open');
    				    	//三秒之后自动消失
    					   setTimeout(function(){
    					    	 $("#charge-saveclinic-win").window('close');
    						 }, 3000);
    					  
     						
     						 //新增交易记录
     						 var charge_moneytype=$(".charge-moneytype").val();
      				 		 if(charge_moneytype==0){
		   	    				  var clinic_ids=$(".clinic_ids").textbox('getValue');
		   						   $.ajax({
		   							   url:'add-chargeRechangeMoney',
		   						      type:'post',
		   						      data:{"clinic_ids":clinic_ids,"rechange_money": appo_totalmoney},
		   						      success:function(data){
			   						    	$(".window-tishi").text("医疗卡收费成功,正在打印小票......");
			   	    				    	$("#charge-saveclinic-win").window('open');
			   	    				    	//三秒之后自动消失
			   	    					    setTimeout(function(){
			   	    					    	 $("#charge-saveclinic-win").window('close');
			   	    						}, 3000);
		   						     }
		   						   });
      				 		 }
     						$("#checkupmoneyhealth-win").window('close');
     						
     						//项目收费显示
          					 $('#chargemoneys-tab').datagrid('appendRow',{
          						 chargemoney_name:'自主体检收费',
          						 chargemoney_allmoney:appo_totalmoney
          					 });
     					      
          					
           					//打印小票---自主体检
           					$(".healthtickettmonoy").css("display","block"); 
        						//获取表格中的信息
        						var drows =$("#checkuphealth-money").datagrid('getRows');
        					    //alert("drows:"+drows);
        						var copyRows = [];
        			            for (var j= 0; j < drows.length; j++) {
        			                copyRows.push(drows[j]); //将数据添加到copyRows数组中    
        			            }
        			            //alert("copyRows:"+drows[j]);
        			            for(var i =0;i<copyRows.length;i++){ 
        							var falg = true;
        							var index = $('#checkuphealth-money').datagrid('getRowIndex',copyRows[i]);
        							//获取追加的表格的行
        							var recordrows = $("#healthtickettmonoy-tab").datagrid("getRows");
        							for(var m=0;m<recordrows.length;m++){
        							     //判断该datagrid在将要添加的数据中是否存在
        							    /*  if(copyRows[i].project_no == recordrows[m].project_no){					      
        							        	falg = false; 
        							        	alert("falg = false");
        							     } */
        							} 
        			                 if(falg){
        			                	 //alert("falg");
        			                	 $("#healthtickettmonoy-tab").datagrid('appendRow',{
        			                		 project_no:drows[i].project_no,
        			                		 project_name:drows[i].project_name,
        			                		 project_price:drows[i]. project_price
        				 		         });
        			                 }
        			            }
        			            
        			         //门诊票据单号
    	  			        $.ajax({
    						      url:'select-chargeMoneyNumberself?appo_no='+appo_no_arr+'&chargemoney_name='+'自主体检收费',
    	   					      type:'post',
    	   					      dataType:'json',
    	   					      success:function(data){
    	   					    	  //票据单号
    	   					    	 $("#health_waternumber").text(data[0]["chargemoney_id"]);
    	   					    	 //票据时间
    	   					    	 var chtime=data[0]["chargemoney_time"];
    	   					 	     $("#health_date").text( comFormatDate(chtime));
    	   					      }
    					    });
        			            
           					//自主体检总费用
           					$("#ticket_healthtotalmoney").text(appo_totalmoney+"/元");
           				    //实收
         					var shimoney=$(".outHealthshishou").val();
         					$("#ticket_healthshimoney").text(shimoney+"/元");
         					//找零
         					var zhaoling=$("#outHealthfoundZero").text(); 
         					$("#ticket_healthfoundzero").text(zhaoling+"/元");
         					
         					 //打开弹框
         					  setTimeout(function(){
 	    					     //打印小票弹框
 	    					     $("#out-ticket-record-win2").window("open");
     					      }, 3000); 
         					 
         					  //关闭打印小票
            				  setTimeout(function(){
       	    					  //打印小票弹框
       	    					 $("#out-ticket-record-win2").window("close");
       	    					 //清除表格
       	    					 $("#checkuphealth-money").datagrid("loadData", {total:0, rows:[]});	
       	    				     //清空实收
     	 				    	 $(".outHealthshishou").textbox("setValue","");
       	    					 $("#chargemoney-clinic-tab").datagrid("reload");
          					  }, 7000); 
     					 }
     					 if(parseInt(data)==2){
     						$("#checkupmoneyhealth-win").window('close');
     						$(".window-tishi").text("自主体检收费失败,请稍后重试......");
    				    	$("#charge-saveclinic-win").window('open');
    				    	//三秒之后自动消失
    					    setTimeout(function(){
    					    	 $("#charge-saveclinic-win").window('close');
    					    	 $(".outHealthshishou").textbox("setValue","");
    					    	  //清空实收
      	 				    	$(".outHealthshishou").textbox("setValue","");
    						 }, 3000);
     					  }
     					}
     				});
         		 }
           });
   
        	
        	
         	//医疗项目收费提交
         	$("#submit-healthprojectmoney").click(function(){
         		var rowa = $("#hospitalhealth-money").datagrid("getRows");
         		//医疗项目记录主表id
                 var hosplookid=rowa[0]["hosp_look_id"];
                 //alert(hosplookid);
                 //医疗项目总金额
			     var total=0;
     			$("<form method='post' id='fors'>").appendTo("body").form({
     				url:'add-HospitalProjectmoney?hosplookid='+hosplookid,
     				onSubmit:function(param){
     					 //看诊id
     				    param["lookillness.lookillnessId"] = $("#chargemoney-sreachbox").textbox("getValue");
 						console.log("看诊编号:"+ param["lookillness.lookillnessId"]);

     				   //收费名称
     					param["chargemoney.chargemoneyName"] ="医疗项目收费";
     					//医疗项目收费类型----1
     					param["chargemoney.chargemoneyType"] = 1;
     					 //经办人
     					 param["chargemoney.chargemoneyPeople"] = $("#chargename").val();
     					//获取表格中的医疗项目信息
     					var rows = $("#hospitalhealth-money").datagrid("getRows");
     					console.log("医疗项目收费："+rows);
     					
     					for (var i = 0; i < rows.length; i++) {
     						//医疗项目记录详情编号
     						param["chargemoneydetails["+i+"].lookHosprojectDetail.hospLookdetailsId"] = rows[i]["hosp_lookdetails_id"];
     						console.log("医疗项目记录详情编号:"+	param["chargemoneydetails["+i+"].lookHosprojectDetail.hospLookdetailsId"] );
     				
     						//医疗项目单价
     					   param["chargemoneydetails["+i+"].lookHosprojectDetail.hospitalProject.hospitalProjectPrice"] =rows[i]["hospital_project_price"];
    					   console.log("医疗项目单价:"+  param["chargemoneydetails["+i+"].lookHosprojectDetail.hospitalProject.hospitalProjectPrice"] );
     					  
   						   //总金额
   						   total+=parseInt( param["chargemoneydetails["+i+"].lookHosprojectDetail.hospitalProject.hospitalProjectPrice"] );
     					}
     				  //医疗项目总金额
     				  param["chargemoney.chargemoneyAllmoney"] =parseInt( total); 
     				  console.log("总金额:"+  param["chargemoney.chargemoneyAllmoney"]);
     				},
     				success:function(data){
     					$(".window-tishi").text("医疗项目收费成功,正在打印小票......");
				    	$("#charge-saveclinic-win").window('open');
				    	//三秒之后自动消失
					   setTimeout(function(){
					    	 $("#charge-saveclinic-win").window('close');
						 }, 3000);
     					 //新增交易记录
     					 var charge_moneytype=$(".charge-moneytype").val();
      					 if(charge_moneytype==0){
	 	    				  var clinic_ids=$(".clinic_ids").textbox('getValue');
	 						   $.ajax({
	 							   url:'add-chargeRechangeMoney',
	 						      type:'post',
	 						      data:{"clinic_ids":clinic_ids,"rechange_money": appo_totalmoney},
	 						      success:function(data){
	 						    	 // alert(data);
	 						     }
	 						   });
      					 }
     					$("#lookmoney-win").window('close');
     					
     					//项目收费
	   					 $('#chargemoneys-tab').datagrid('appendRow',{
	   						 chargemoney_name:'医疗项目收费',
	   						 chargemoney_allmoney:total
	   					 });
     					
	   					//打印小票---医疗项目
       					$(".hostickettmonoy").css("display","block"); 
    						//获取表格中的信息
    						var drows =$("#hospitalhealth-money").datagrid('getRows');
    					    //alert("drows:"+drows);
    						var copyRows = [];
    			            for (var j= 0; j < drows.length; j++) {
    			                copyRows.push(drows[j]); //将数据添加到copyRows数组中    
    			            
    			            }
    			            //alert("copyRows:"+drows);
    			            for(var i =0;i<copyRows.length;i++){ 
    							var falg = true;
    							var index = $('#hospitalhealth-money').datagrid('getRowIndex',copyRows[i]);
    							//获取追加的表格的行
    							var recordrows = $("#hostickettmonoy-tab").datagrid("getRows");
    							for(var m=0;m<recordrows.length;m++){
    							     //判断该datagrid在将要添加的数据中是否存在
    							   /*   if(copyRows[i].hospital_project_id == recordrows[m].hospital_project_id){					      
    							        	falg = false; 
    							        	//alert("falg = false");
    							     } */
    							} 
    			                 if(falg){
    			                	 //alert("falg");
    			                	 $("#hostickettmonoy-tab").datagrid('appendRow',{
    			                		 hospital_project_id:drows[i].hospital_project_id,
    			                		 hospital_project_name:drows[i]. hospital_project_name,
    			                		 hospital_project_price:drows[i].hospital_project_price
    				 		         });
    			                 }
    			            }
    			            var look_number=$("#chargemoney-sreachbox").textbox("getValue");
     			            $.ajax({
    						      url:'select-chargeMoneyNumber',
    	   					      type:'post',
    	   					      data:{"look_number":look_number,"chargemoney_name": "医疗项目收费"},
    	   					      success:function(data){
    	   					    	 $("#hos_waternumber").text(data[0]["chargemoney_id"]);
    	   					    	 var chtime=data[0]["chargemoney_time"];
    	   					 	     $("#hos_date").text( comFormatDate(chtime));
    	   					      }
    					    });    
    			            
       					//医疗项目总费用
       					$("#ticket_hostotalmoney").text(total+"/元");
       				     //实收
    					var shimoney=$(".hosProjectshishou").val();
    					$("#ticket_hosshimoney").text(shimoney+"/元");
    					//找零
    					var zhaoling=$("#outHealthfoundZero").text(); 
    					 $("#ticket_hosfoundzero").text(zhaoling+"/元");
    					 
    					 //打开弹框
    					 setTimeout(function(){
	    					  //打印小票弹框
    						  $("#out-ticket-record-win3").window("open");
    					   }, 3000); 
    					
    					//关闭打印小票
        				setTimeout(function(){
   	    					  //打印小票弹框
   	    					 $("#out-ticket-record-win3").window("close");
   	    					//清除表格
   	    					$("#hospitalhealth-money").datagrid("loadData", {total:0, rows:[]});
   	    				    //清空实收
	 				    	$(".hosProjectshishou").textbox("setValue","");
      					}, 7000);  
     				}
     			}).submit();
         		
         	});
        	
        	
        	//药物收费提交
        	$("#submit-drugmoney").click(function(){
        		//药品总金额
				var total=0;
        		//for表单提交药物收费
        		$("<form method='post' id='fors'>").appendTo("body").form({
    				url:'add-drugmoney',
    				onSubmit:function(param){
    					 //看诊id
    				    param["lookillness.lookillnessId"] = $("#chargemoney-sreachbox").textbox("getValue");
						console.log("看诊编号:"+ param["lookillness.lookillnessId"]);

    				   //收费名称
    					param["chargemoney.chargemoneyName"] ="药物收费";
    					//收费类型----0
    					param["chargemoney.chargemoneyType"] = 0;
    					 //经办人
    					 param["chargemoney.chargemoneyPeople"] = $("#chargename").val();
    					//获取表格中的药品信息
    					var rows = $("#drugmoneytab").datagrid("getRows");
    					console.log("药物收费："+rows);
    					//每个药品总金额
    					var everytotal=0;
    					
    					for (var i = 0; i < rows.length; i++) {
    						//医嘱详情编号
    						param["chargemoneydetails["+i+"].doctoradviceDetail.docdetailsId"] = rows[i]["docdetails_id"];
    						console.log("医嘱详情编号:"+param["chargemoneydetails["+i+"].doctoradviceDetail.docdetailsId"] );
    						
    						//医嘱详情药品的单个数量
    					    param["chargemoneydetails["+i+"].doctoradviceDetail.docdetailsEverynnum"] =rows[i]["docdetails_everynnum"];
    						console.log("医嘱详情药品的单个数量:"+  param["chargemoneydetails["+i+"].doctoradviceDetail.docdetailsEverynnum"] );

    						//医嘱详情药品药品单价
    					   param["chargemoneydetails["+i+"].doctoradviceDetail.drug.drugRetailPrice"] =rows[i]["drug_retail_price"];
   						   console.log("医嘱详情药品药品单价:"+ param["chargemoneydetails["+i+"].doctoradviceDetail.drug.drugRetailPrice"] );
    					  
   						   //单价乘以数量
   						   everytotal=parseInt( param["chargemoneydetails["+i+"].doctoradviceDetail.docdetailsEverynnum"])*parseInt( param["chargemoneydetails["+i+"].doctoradviceDetail.drug.drugRetailPrice"] )
  						   console.log("单价乘以数量:"+ parseInt(everytotal) );
   						   //总金额
   						   total+=parseInt(everytotal);
   						   
    					}
    				  //药品总金额
    				  param["chargemoney.chargemoneyAllmoney"] =parseInt( total); 
    				  console.log("总金额:"+  param["chargemoney.chargemoneyAllmoney"]);
    				},
    				success:function(data){
   					    $(".window-tishi").text("药物收费成功,正在打印小票......");
				    	$("#charge-saveclinic-win").window('open');
				    	
				    	//三秒之后自动消失
					     setTimeout(function(){
					    	 $("#charge-saveclinic-win").window('close');
						 }, 3000);
    				  //新增交易记录
    				 var charge_moneytype=$(".charge-moneytype").val();
    				  if(charge_moneytype==0){
    					  var clinic_ids=$(".clinic_ids").textbox('getValue');
	   					   $.ajax({
	   						      url:'add-chargeRechangeMoney',
		   					      type:'post',
		   					      data:{"clinic_ids":clinic_ids,"rechange_money": total},
		   					      success:function(data){
		   					    	  //alert(data);
		   					      }
	   					   });
    				  }
    				    //关闭弹框
    					$("#drugmoney-win").window('close');
    					
    					//项目收费
    					 $('#chargemoneys-tab').datagrid('appendRow',{
    						 chargemoney_name:'药物收费',
    						 chargemoney_allmoney:total
    					 });
    					
    					//打印小票---药物
    					$(".drugtickettmonoy ").css("display","block"); 
    					//$("#drugtickettmonoy-tab ").css("display","block"); 
 						//获取表格中的信息
 						var drows =$("#drugmoneytab").datagrid('getRows');
 					    //alert("drows:"+drows);
 						var copyRows = [];
 			            for (var j= 0; j < drows.length; j++) {
 			                copyRows.push(drows[j]); //将数据添加到copyRows数组中    
 			            
 			            }
 			            //alert("copyRows:"+drows[j]);
 			            for(var i =0;i<copyRows.length;i++){ 
 							var falg = true;
 							var index = $('#drugmoneytab').datagrid('getRowIndex',copyRows[i]);
 							//获取追加的表格的行
 							var recordrows = $("#drugtickettmonoy-tab").datagrid("getRows");
 							for(var m=0;m<recordrows.length;m++){
 							     //判断该datagrid在将要添加的数据中是否存在
 							     if(copyRows[i].docdetails_id == recordrows[m].docdetails_id){					      
 							        	falg = false; 
 							        	//alert("falg = false");
 							     }
 							} 
 			                 if(falg){
 			                	 //alert("falg");
 			                	 $("#drugtickettmonoy-tab").datagrid('appendRow',{
 			                		 docdetails_id:drows[i].docdetails_id,
 			                		 category_name:drows[i].category_name,
 			                		 drug_name:drows[i].drug_name,
 			                		 drug_retail_price:drows[i].drug_retail_price,
 			                		 drug_unit:drows[i].drug_unit,
 			                		 docdetails_everynnum:drows[i].docdetails_everynnum
 				 		         });
 			                 }
 			            }
 			            //收费单号
 			            //根据看诊号与收费类型查到药物收费单号
 			            var look_number=$("#chargemoney-sreachbox").textbox("getValue");
 			            $.ajax({
						      url:'select-chargeMoneyNumber',
	   					      type:'post',
	   					      data:{"look_number":look_number,"chargemoney_name": "药物收费"},
	   					      success:function(data){
	   					    	 $("#drug_waternumber").text(data[0]["chargemoney_id"]);
	   					    	 var chtime=data[0]["chargemoney_time"];
	   					 	     $("#drug_date").text( comFormatDate(chtime));
	   					      }
					    });
 			            
 			            //患者姓名
 			            var uname=$("#chargemoney-sickuname").textbox("getValue");
 			            $("#ticket_uname").text(uname);
 			            var usex=$("#chargemoney-patientsex").combobox('getValue');
 			            $("#ticket_usex").text(usex);
    					//药物应收
    					$("#ticket_drugtotalmoney").text(total+"/元");
    					//实收
    					var shimoney=$(".shishou").val();
    					$("#ticket_drugshimoney").text(shimoney+"/元");
    					//找零
    					var zhaoling=$("#drugfoundZero").text(); 
    					$("#ticket_drugfoundzero").text(zhaoling+"/元");
    					   setTimeout(function(){
	    					  //打印小票弹框
	    					 $("#out-ticket-record-win").window("open");
    					   }, 3000); 
    					 
    					//关闭打印小票
     				    setTimeout(function(){
 	    					  //打印小票弹框
 	    					 $("#out-ticket-record-win").window("close");
 	    					//清除表格
 	     				    $("#drugmoneytab").datagrid("loadData", {total:0, rows:[]});
 	     				     //清空实收
 					    	$(".shishou").textbox("setValue","");
   					    }, 7000)
    					
    				}
    			}).submit();
        		
        	});
        
         	
            //看诊号搜索框网格
      		$("#chargemoney-sreachbox").searchbox({
      				searcher:function(value,name){
     					$("#chargemoney-record-win").window("open");
      				}
      			});
             	
             	$("#chargemoney-record-tab").datagrid({
             		url:'select-NoChargePeople',
        			    pagination:true,
        			    pageNumber:1,
        			    pageSize:10,
        			    pageList:[10,20],
        			    columns:[[
        			    	    {field:'lookillness_id',title:'看诊编号',width:80},
        			    		{field:'clinic_id',title:'医疗编号',width:126,hidden:true},
        			    	 	{field:'cliniccard_id',title:'医疗卡号',width:126},
        			    		{field:'clinic_name',title:'病人名字',width:120},
        						{field:'clinic_sex',title:'性别',width:50},
        						{field:'clinic_idnumber',title:'身份证号',width:160},
        						{field:'clinic_tel',title:'电话',width:120},
        						{field:'clinic_address',title:'家庭住址',width:153},
        						{field:'clinic_remainmoney',title:'余额',width:80}
        			    ]]
             	});
             	
             	//双击获取
     			$("#chargemoney-record-tab").datagrid({
     				onDblClickRow: function(rowIndex,rowData){
     					    //看诊编号
	                        $("#chargemoney-sreachbox").textbox('setValue',rowData['lookillness_id']); 
	                        //$("#chargemoney-sreachbox").textbox('readonly','true');
     					     //医疗卡
		                     $("#mclinic-sreachbox").textbox('setValue',rowData['cliniccard_id']); 
		                     //$("#mclinic-sreachbox").textbox('readonly','true');
		                     
		                     $("#ticket_ucliniccard").text(rowData['cliniccard_id']); 
		                     $("#ticket_ucliniccard2").text(rowData['cliniccard_id']); 
		                     $("#ticket_ucliniccard3").text(rowData['cliniccard_id']); 
     					     
		                     //患者姓名
		                     $("#chargemoney-sickuname").textbox('setValue',rowData['clinic_name']); 
		                      
		                     $("#ticket_uname2").text(rowData['clinic_name']); 
		                     $("#ticket_uname3").text(rowData['clinic_name']);
		                     
		                    //患者性别
		                    $("#chargemoney-patientsex").combobox('setValue',rowData['clinic_sex']);
		                    $("#ticket_usex2").text(rowData['clinic_sex']);
		                    $("#ticket_usex3").text(rowData['clinic_sex']);
		                    
		                    //身份证号
		                    $("#chargemoney-sickusercard").textbox('setValue',rowData['clinic_idnumber']);
		                    //手机号码
		                    $("#chargemoney-sickuserTel").textbox('setValue',rowData['clinic_tel']);
		                    //家庭住址
		                    $("#clinic_address").textbox('setValue',rowData['clinic_address']);
		                    //余额
		                    $(".clinic_remainmoney").textbox('setValue',rowData['clinic_remainmoney']);
		                    
		                    //医疗卡主键
		                    $(".clinic_ids ").textbox('setValue',rowData['clinic_id']);
		                    
		                    //关闭窗口
		               	   $("#chargemoney-record-win").window("close");
     				}
     		  				
     			});
             	
             	//默认显示
     			 projectmoney("");
             	
             	
            $.extend($.fn.textbox.defaults.rules, {
            	 //药品收费应收验证与计算找零
				 drugmony_rules: {
				        validator: function(value, param) {
				            var reg = /^[0-9]*$/;
				            return reg.test(value);
				        },
				        message: "金额请输入数字"
				    },
				    drugmoney_size:{
				        validator: function(value, param) {
				        	   //实收-应收=找零
				          	  var yinshou=$("#drugMoneys").text();
				          	  if(value>=yinshou){
				          		  //alert(yinshou+":-----:"+value+"==="+(value>=yinshou));
				          		  console.log(yinshou+":-----:"+value+"==="+(value>=yinshou));
				          		  var zhaoling=parseInt(value)-parseInt(yinshou);
				          		  $("#drugfoundZero").text(parseInt(zhaoling));
				          		  return value;
				          		  //console.log("药物应收："+yinshou+"-----------实收："+shishou+"----------找零："+zhaoling);
				          	  }
				        },
				        message: "实收必须大于等于应收"
				    },
                   //自主体检与门诊体检验证
				   healthmoney_rules:{
				        validator: function(value, param) {
				        	    var reg = /^[0-9]*$/;
					            return reg.test(value);
			            },
			          message: "金额请输入数字"
			      },
			      healthmoney_size:{
				        validator: function(value, param) {
				      	      //应收
				          	  var yinshou=$("#outHealthMoneys").text();
				          	  if(value>=yinshou){
				          		  var zhaoling=parseInt(value)-parseInt(yinshou);
				          		  $("#outHealthfoundZero").text(parseInt(zhaoling));
				          		  return true;
				          		 //console.log("体检应收："+yinshou+"-----------实收："+shishou);
				          	  }
		                },
		                message: "实收必须大于等于应收"
		        },
		        //医疗项目
		        hosmoney_rules:{
			        validator: function(value, param) {
		        	    var reg = /^[0-9]*$/;
			            return reg.test(value);
	            },
		          message: "金额请输入数字"
		      },
		      hosmoney_size:{
			        validator: function(value, param) {
			      	      //应收
			          	  var yinshou=$("#hosProjectMoneys").text();
			          	  if(value>=yinshou){
			          		  var zhaoling=parseInt(value)-parseInt(yinshou);
			          		 $("#hosProjectfoundZero").text(parseInt(zhaoling));
			          		    return value;
			           	       // console.log("医疗项目应收："+yinshou+"-----------实收："+shishou);
			          	  }
	                },
	                message: "实收必须大于等于应收"
	           }
           });
        	
         }) ;
         
         
         //项目收费
         function projectmoney(){
        	 //项目收费
        	 var lookid=$("#chargemoney-sreachbox").textbox("getValue");
        	 $('#chargemoneys-tab').datagrid({
 			    url:'select-Money?lookid='+lookid,
 			    pagination:true,
 			    pageNumber:1,
 			    pageSize:3,
 			    pageList:[3,6],
 			    columns:[[
 			    		/* {field:'chargemoney_id',title:'项目编号',width:316}, */
			    	 	{field:'chargemoney_name',title:'项目名称',width:508},
						{field:'chargemoney_allmoney',title:'总金额',width:508}
 			    ]]
 			});
         }
         
         //自主体检项目收费
         function selftmoney(){
			 var ccardid=$("#mclinic-sreachbox").textbox("getValue");
				 $('#chargemoneys-tab').datagrid({
	 			    url:'select-selfMoney?ccardid='+ccardid,
	 			    pagination:true,
	 			    pageNumber:1,
	 			    pageSize:3,
	 			    pageList:[3,6],
	 			    columns:[[
				    	 	{field:'chargemoney_name',title:'项目名称',width:508},
							{field:'chargemoney_allmoney',title:'总金额',width:508}
	 			    ]]
	 			});
         }
         
         //计算门诊体检找零
   /*       function  outHealthMoney(){
        	 //实收-应收=找零
        	 var yinshou=$("#outHealthMoneys").text();
        	 var shishou=$(".outHealthshishou").val();
        	 console.log("应收："+yinshou+"-----------实收："+shishou);
        	 var zhaoling=parseInt(shishou)-parseInt(yinshou);
        	  $("#outHealthfoundZero").text(parseInt(zhaoling));
         } */
         
         //计算医疗项目找零
        /*    function  HosProjectMoney(){
        	 //实收-应收=找零
        	 var yinshou=$("#hosProjectMoneys").text();
        	 var shishou=$(".hosProjectshishou").val();
        	 console.log("应收："+yinshou+"-----------实收："+shishou);
        	 var zhaoling=parseInt(shishou)-parseInt(yinshou);
        	 $("#hosProjectfoundZero").text(parseInt(zhaoling));
         } */
         
   		//格式化时间
   		function comFormatDate(date) {
   			var day = new Date(date); 
   			var Year = 0; 
   			var Month = 0; 
   			var Day = 0; 
   			var CurrentDate = ""; 
   			//初始化时间 
   			Year= day.getFullYear();//ie火狐下都可以 
   			Month= day.getMonth()+1; 
   			Day = day.getDate(); 
   			Hour = day.getHours(); 
   			 Minute = day.getMinutes(); 
   			 Second = day.getSeconds(); 
   			CurrentDate += Year + "-"; 
   			if (Month >= 10 ) { 
   				CurrentDate += Month + "-"; 
   			}else { 
   				CurrentDate += "0" + Month + "-"; 
   			} 
   			if (Day >= 10 ) { 
   				CurrentDate += Day ; 
   			}else { 
   				CurrentDate += "0" + Day ; 
   			} 
   			if(Hour>=10){
   				CurrentDate +=" "+Hour;
   			}else{
   				CurrentDate +=" "+"0"+Hour;
   			}
   			if(Minute>=10){
   				CurrentDate +=":"+Minute;
   			}else{
   				CurrentDate +=":"+"0"+Minute;
   			}
   			if(Second>=10){
   				CurrentDate +=":"+Second;
   			}else{
   				CurrentDate +=":"+"0"+Second;
   			}
   			return CurrentDate; 
   		}
    
</script>

<fieldset style="border:1px solid #A6A6A6;border-radius:6px;width:1050px;margin:0 auto;margin-top:20px;margin-bottom:20px;">
       <legend style="font-size:17px">基本信息</legend>
       <div class="charge-money-one" style="margin-top: 15px;">
		          <a>
		            <span style="margin-right:7px;"> 看诊单号</span>
		             <input id="chargemoney-sreachbox" class="easyui-searchbox"  data-options="width:130,height:30,required:true"/>
		         </a>
		             
		             <a style="margin-left:40px;">
		             	<span style="margin-right:7px;">医疗卡号</span>
		             <input id="mclinic-sreachbox" class="easyui-searchbox"  data-options="width:130,height:30,required:true"/>
		            </a>
		            
		            <a style="margin-left:40px;">
		            	 <span style="margin-right:7px;">患者姓名</span>
						 <input id="chargemoney-sickuname" name="lookdoctor-sickuname" class="easyui-textbox"  data-options="width:130,height:30,required:true,readonly:true">
					</a>
		
				<a style="margin-left:40px;">
		   			    <span style="margin-right:35px;">性别</span>
						<span class="chargemoneyr-lusexbox">
						<select id="chargemoney-patientsex" class="easyui-combobox" data-options=" panelHeight:'auto',readonly:true" style="width:100px; height: 30px;line-height: 30px;">
							   <option>男</option>
							   <option>女</option>
						</select>
						</span>
				</a>
         </div>
         <div class="charge-money-two">
			<a >
			 	   <span style="margin-right:7px;">联系电话</span>
			       <input id="chargemoney-sickuserTel" class="easyui-textbox"  data-options="width:130,height:30,required:true,readonly:true"/>
			</a>
			
			<a style="margin-left:40px;">
					<span style="margin-right:7px;">家庭住址</span>
			  		 <input id="clinic_address" class="caddress easyui-textbox"  data-options="width:130,height:30,required:true,readonly:true"></input>	
			</a>
			
			<a style="margin-left:40px;">
					     <span style="margin-right:7px;"> 身份证号</span>
		                  <input id="chargemoney-sickusercard" class="easyui-textbox"  data-options="width:130,height:30,required:true,readonly:true"/>
			 </a>
			 
			<a style="margin-left:42px;"> 
		      	   <span style="margin-right:7px;">付款方式</span>
				    <select  class="charge-moneytype"  style="width: 100px;height: 30px;line-height: 30px;border-radius: 5px;">
						   <option  value="1" selected="selected">现金</option>
						   <option  value="0">医疗卡</option>
				    </select>
		    </a>
		    <!--  余额 -->
		    <input class="clinic_remainmoney  easyui-textbox"  type="hidden">
		    <!--  医疗卡主键 -->
		     <input class="clinic_ids  easyui-textbox"  type="hidden">
		      <!--  <a style="margin-left:40px;">
		            <span style="margin-right:7px;">处方编号</span>
			        <input id="chargemoney-dadviceid" class="easyui-textbox"  data-options="width:130,height:30,required:true"></input>
		       </a> -->
		       
		    <div style="width:360px;margin:0 auto;margin-left:69.5%;display:inline-block;margin-top:30px;">
		           <div style=" float:left;">
			            <a  class="drugmoney easyui-linkbutton"   data-options="iconCls:'icon-add',border:false" >处方收费</a> 
			       </div>  
			        <div style=" float:left; margin-left:6px;">   
			            <a  class="checkup-moneybtn easyui-linkbutton"   data-options="iconCls:'icon-add',border:false" >体检收费</a> 
			        </div> 
			        <div style=" float:left; margin-left:6px;">    
			            <a  class="lookdoctormoney easyui-linkbutton"   data-options="iconCls:'icon-add',border:false" >医疗项目收费</a> 
			         </div>   
			        <!--   <div style=" float:left; margin-left:6px;">    
			            <a  class="moneyticket easyui-linkbutton"   data-options="iconCls:'icon-add',border:false" >打印小票</a> 
			         </div>    -->
			</div>
       </div>
   </fieldset>    
   
<!--    收费管理 -->
<div id="out-charge-details" class="easyui-tabs"  style="overflow: hidden;width:1070px;margin-left:4%;float:left;border: 1px solid #bbb;">
    <div title="项目收费" style="padding:20px;overflow: hidden;width:1070px;height:140px;" >
		    <table id="chargemoneys-tab" class="easyui-datagrid" data-options="fitColumns:false,singleSelect:false,width:1020,height:135" >
				    
			</table>
    </div>

  
</div><!-- 收费最大plane -->

    
    <!-- 处方收费 -->
    <div id="drugmoney-win" class="easyui-window" title="处方收费" style="width:800px;height:480px"
			    data-options="iconCls:'icon-save',modal:true,resizable:false,collapsible:false,maximizable:false,minimizable:false,closed:true">
		    <table id="drugmoneytab" class="easyui-datagrid" data-options="fitColumns:false,width:785,height:300" >
			
			</table>
			<div style="font-size: 15px;padding: 20px;margin-top: 10px;">
			     <span style="display: inline-block;margin-right: 30px;">应收：
			    			 <a  id="drugMoneys" style="color:red"></a>
			     </span>
			     <span style="margin-right: 30px;">实收：
			     		<a style="color:red"><!-- data-options="width:120,events:{blur:CalcDrugMoney}"  onkeyup="CalcDrugMoney()"-->
			     		<input class="shishou easyui-textbox"  id="drugshishou" style="width:120px;"  data-options="height:27,required:true,validType:['drugmony_rules','drugmoney_size']">
			     		</a>
			     </span>
			     <span>找零：<a id="drugfoundZero" style="color:red"></a></span>
		   </div>
		   
		<p><a id="submit-drugmoney" data-options="iconCls:'icon-ok'" style="margin-left:43%;margin-top:10px;"class="easyui-linkbutton">提交</a><p>
	</div><!-- 处方最大盒子 -->
	
	<!-- 体检收费 -->
    <div id="checkupmoneyhealth-win" class="easyui-window" title="体检收费" style="width:800px;height:500px"
			    data-options="iconCls:'icon-save',modal:true,resizable:false,collapsible:false,maximizable:false,minimizable:false,closed:true">
		    <table id="checkuphealth-money" class="easyui-datagrid" data-options="fitColumns:false,singleSelect:false,width:785,height:300" >
				  
			 </table>
			 <div style="font-size: 15px;padding: 20px;margin-top: 10px;">
			     <span style="display: inline-block;margin-right: 30px;">应收：
			    			 <a  id="outHealthMoneys" style="color:red"></a>
			     </span>
			     <span style="margin-right: 30px;">实收：
			     		<a style="color:red">
			     		<input class="outHealthshishou easyui-textbox"  name="outHealthshishou"  style="width:120px;" data-options="height:27,required:true,validType:['healthmoney_rules','healthmoney_size']">
			     		</a>
			     </span>
			     <span>找零：<a id="outHealthfoundZero" style="color:red"></a></span>
		   </div>
		<p><a id="submit-chekhealthmoney" data-options="iconCls:'icon-ok'" style="margin-left:43%;margin-top:10px;"class="easyui-linkbutton">提交</a><p>
	</div><!--体检收费最大盒子 -->
	
		<!-- 医疗项目收费 -->
    <div id="lookmoney-win" class="easyui-window" title="医疗项目收费" style="width:800px;height:500px"
			    data-options="iconCls:'icon-save',modal:true,resizable:false,collapsible:false,maximizable:false,minimizable:false,closed:true">
		    <table id="hospitalhealth-money" class="easyui-datagrid" data-options="fitColumns:false,singleSelect:false,width:785,height:300" >
				   
			 </table>
			 
			  <div style="font-size: 15px;padding: 20px;margin-top: 10px;">
			     <span style="display: inline-block;margin-right: 30px;">应收：
			    			 <a  id="hosProjectMoneys" style="color:red"></a>
			     </span>
			     <span style="margin-right: 30px;">实收：
			     		<a style="color:red">
			     		<input class="hosProjectshishou easyui-textbox"  style="width:120px;" data-options="height:27,required:true,validType:['hosmoney_rules','hosmoney_size']">
			     		</a>
			     </span>
			     <span>找零：<a id="hosProjectfoundZero" style="color:red"></a></span>
		   </div>
			 
		<p><a id="submit-healthprojectmoney" data-options="iconCls:'icon-ok'" style="margin-left:43%;margin-top:10px;"class="easyui-linkbutton">确定</a><p>
	</div><!-- 医疗项目最大盒子 -->

    <input type="hidden" value="${user.userName}"  id="chargename">
    
    <!-- 看诊搜索框 -->		
	<div id="chargemoney-record-win" class="easyui-window" title="看诊病人信息" style="width:905px;height:400px"
    data-options="iconCls:'icon-save',closed:true,modal:true,shadow:true,resizable:false,collapsible:false,minimizable:false,maximizable:false">
		<table  id="chargemoney-record-tab"   style="height:360px;">
		 
		</table>
     </div>
     
       <!-- 医疗卡搜索框 -->		
	  <div id="chargemoney-clinic-win" class="easyui-window" title="病人信息" style="width:825px;height:400px"
       data-options="iconCls:'icon-save',closed:true,modal:true,shadow:true,resizable:false,collapsible:false,minimizable:false,maximizable:false">
		<table  id="chargemoney-clinic-tab"   style="height:360px;">
		 
		</table>
      </div>
     
   <!--   药物打印小票 -->
     <div id="out-ticket-record-win" class="easyui-window" title="药物收费小票" style="width:770px;height:500px"
	    data-options="iconCls:'icon-save',closed:true,modal:true,shadow:true,resizable:false,collapsible:false,minimizable:false,maximizable:false">
		     <p style="font-size:20px;text-align:center;">XXX医院门诊药物收费收据</p>
		     
		     <a style="margin-left:20px;">票据流水单号:
		             <a id="drug_waternumber"></a>
		     </a>
		     <a style="margin-left:55%;">票据日期:
		          	<a id="drug_date"></a>
		      </a>
		    <div style="font-size: 16px;margin-left: 20px;margin-top:35px;">
		         <span style="margin-right:7px;">患者姓名</span>
		         <a id="ticket_uname"style="border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		         <span style="margin-right:7px;margin-left: 50px;">患者性别</span>
		         <a   id="ticket_usex" style="border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		         <span style="margin-right:7px;margin-left: 50px;">医疗卡号</span>
		         <a   id="ticket_ucliniccard" style="border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		    </div>
		      <div style="font-size: 16px;margin-left: 20px;margin-top:25px;">
		          <span style="margin-right:38px;">应收</span>
		          <a id="ticket_drugtotalmoney"style="color:red;border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		           <span style="margin-right:38px;margin-left: 50px;">实收</span>
		         <a   id="ticket_drugshimoney" style="border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		         <span style="margin-right:38px;margin-left: 50px;">找零</span>
		         <a   id="ticket_drugfoundzero" style="color:red;border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		     </div>
		     <div style="font-size: 16px;margin-left: 20px;margin-top:25px;">
		       <span style="margin-right:21px;">经办人</span>
		         <a id="ticket_uregpeople"style="border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;">${user.userName}</a>
		    </div>
		    <!-- 药物 -->
		     <div class="drugtickettmonoy"  style="display:none;/* border:1px solid #bbb; */width:707px;font-size:16px;margin-left: 20px;margin-top:10px;height:165px;">
		           <table id="drugtickettmonoy-tab"  class="easyui-datagrid" style="width:707px;height:162px;">
		           
		          </table>
		    </div><!-- 药物总费用 -->
		    
      </div>
      
   <!--   体检打印小票 -->
     <div id="out-ticket-record-win2" class="easyui-window" title="体检收费小票" style="width:770px;height:500px"
	    data-options="iconCls:'icon-save',closed:true,modal:true,shadow:true,resizable:false,collapsible:false,minimizable:false,maximizable:false">
		     <p style="font-size:20px;text-align:center;">XXX医院体检收费收据</p>
		     
		     <a style="margin-left:20px;">票据流水单号:
		             <a id="health_waternumber"></a>
		     </a>
		     <a style="margin-left:55%;">票据日期:
		          	<a id="health_date"></a>
		      </a>
		    <div style="font-size: 16px;margin-left: 20px;margin-top:35px;">
		         <span style="margin-right:7px;">患者姓名</span>
		         <a id="ticket_uname2"style="border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		         <span style="margin-right:7px;margin-left: 50px;">患者性别</span>
		         <a   id="ticket_usex2" style="border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		         <span style="margin-right:7px;margin-left: 50px;">医疗卡号</span>
		         <a   id="ticket_ucliniccard2" style="border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		    </div>
		      <div style="font-size: 16px;margin-left: 20px;margin-top:25px;">
		          <span style="margin-right:38px;">应收</span>
		          <a id="ticket_healthtotalmoney"style="color:red;border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		           <span style="margin-right:38px;margin-left: 50px;">实收</span>
		         <a   id="ticket_healthshimoney" style="border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		         <span style="margin-right:38px;margin-left: 50px;">找零</span>
		         <a   id="ticket_healthfoundzero" style="color:red;border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		     </div>
		     <div style="font-size: 16px;margin-left: 20px;margin-top:25px;">
		       <span style="margin-right:21px;">经办人</span>
		         <a id="ticket_healthpeople"style="border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;">${user.userName}</a>
		    </div>
		  
		     <!-- 体检 -->
		     <div class="healthtickettmonoy" style="display:none;/* border:1px solid #bbb; */width:707px;font-size:16px;margin-left: 20px;margin-top:12px;height:165px;">
		           <table id="healthtickettmonoy-tab"  class="easyui-datagrid"  style="width:707px;height:162px;">
		             
		          </table>
		    </div><!-- 体检总费用 -->
      </div>  
      
      <!--  医疗项目打印小票 -->
     <div id="out-ticket-record-win3" class="easyui-window" title="医疗项目小票" style="width:770px;height:500px"
	    data-options="iconCls:'icon-save',closed:true,modal:true,shadow:true,resizable:false,collapsible:false,minimizable:false,maximizable:false">
		     <p style="font-size:20px;text-align:center;">XXX医院医疗项目收费收据</p>
		     
		     <a style="margin-left:20px;">票据流水单号:
		             <a id="hos_waternumber"></a>
		     </a>
		     <a style="margin-left:55%;">票据日期:
		          	<a id="hos_date"></a>
		      </a>
		    <div style="font-size: 16px;margin-left: 20px;margin-top:35px;">
		         <span style="margin-right:7px;">患者姓名</span>
		         <a id="ticket_uname3"style="border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		         <span style="margin-right:7px;margin-left: 50px;">患者性别</span>
		         <a   id="ticket_usex3" style="border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		         <span style="margin-right:7px;margin-left: 50px;">医疗卡号</span>
		         <a   id="ticket_ucliniccard3" style="border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		    </div>
		     <div style="font-size: 16px;margin-left: 20px;margin-top:25px;">
		          <span style="margin-right:38px;">应收</span>
		          <a id="ticket_hostotalmoney"style="color:red;border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		           <span style="margin-right:38px;margin-left: 50px;">实收</span>
		         <a   id="ticket_hosshimoney" style="border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		         <span style="margin-right:38px;margin-left: 50px;">找零</span>
		         <a   id="ticket_hosfoundzero" style="color:red;border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;"></a>
		     </div>
		     <div style="font-size: 16px;margin-left: 20px;margin-top:25px;">
		       <span style="margin-right:21px;">经办人</span>
		         <a id="ticket_hospeople"style="border-bottom:1px solid #bbb;display: inline-block;width:125px;text-align:center;">${user.userName}</a>
		    </div>
		  
		     <!-- 医疗项目-->
		     <div class="hostickettmonoy" style="display:none;border:1px solid #bbb;width:707px;font-size:16px;margin-left: 20px;margin-top:12px;height:165px;">
		           <table id="hostickettmonoy-tab" class="easyui-datagrid"  style="width:707px;height:162px;">
		            
		          </table>
		    </div><!-- 医疗项目总费用 -->
		    
      </div> 
<!-- 弹框提示 -->
<div id="charge-saveclinic-win" class="easyui-window"  title="提示框" style="width:373px;height:165px"
    data-options="iconCls:'icon-save',modal:true,resizable:false,collapsible:false,maximizable:false,minimizable:false,closed:true">
          <p class="window-tishi" style=" margin-left: 60px;font-size: 16px;margin-top: 47px;">123456
          </p>
</div>
    
</body>
</html>